import { useTable, LIST_TYPE } from '@crud/index';
import { activityList } from '@/api/crm-kgj/activity';
import { slotProductList } from '@/api/crm-kgj/slot';

/** 商品状态 */
export const skuStatusOptions = [
  { label: '不限', value: '' },
  { label: '已失效', value: 3 },
  { label: '上架', value: 1 },
  { label: '下架', value: 2 }
];
export const skuStatusMaps: any = {
  1: '上架',
  2: '下架',
  3: '已失效'
};
/** 活动状态 */
export const activityStatusMaps: any = {
  1: '上架中',
  2: '已下架',
  3: '未开始',
  4: '已结束'
};

export const useTableListActivity = (options: any = {}) => {
  const columns = [
    { label: 'Banner', prop: 'main_banner_url', render: 'main_banner_url', align: 'center', width: 186 },
    { label: '活动标题', prop: 'title', align: 'center', minWidth: 250 },
    { label: '关联活动信息ID', prop: 'activity_id', render: 'activity_id', align: 'center', width: 150 },
    { label: '活动时间', prop: 'time', render: 'time', align: 'center', minWidth: 210 },
    { label: '优先级', prop: 'priority', align: 'center', width: 122 },
    { label: '活动状态', prop: 'status', render: 'status', align: 'center', width: 122 },
    { label: '操作', prop: 'actions', render: 'actions', minWidth: 120, align: 'center' }
  ];

  return useTable({
    ...options,
    type: LIST_TYPE.KGJ,
    columns,
    getList: activityList
  });
};

export const useTableListSlot = (options: any = {}) => {
  const columns = [
    { label: '商品信息', prop: 'product', render: 'product', align: 'left', minWidth: 273 },
    { label: '商品ID', prop: 'product_id', align: 'left', width: 120, type: 'copy', showOverflowTooltip: true },
    { label: '店铺', prop: 'shop', render: 'shop', align: 'center', minWidth: 120 },
    { label: '价格', prop: 'price', align: 'right', width: 120, type: 'priceCent', sortable: true },
    { label: '佣金', prop: 'cos_ratio', render: 'cos_ratio', align: 'right', width: 120, sortable: true },
    { label: '商品状态', prop: 'status', render: 'status', align: 'center', width: 120 },
    { label: '关联橱窗数', prop: 'shop_count', render: 'shop_count', align: 'center', width: 120, sortable: true },
    { label: '上架时间', prop: 'put_time', type: 'dateTime', align: 'center', width: 180, sortable: true },
    { label: '优先级', prop: 'priority', align: 'center', width: 120 },
    { label: '操作', prop: 'actions', render: 'actions', minWidth: 180, align: 'center', fixed: 'right' }
  ];

  return useTable({
    ...options,
    type: LIST_TYPE.KGJ,
    params: {
      status: ''
    },
    columns,
    getList: ({ params, data }: any) => {
      return slotProductList({ params, data });
    }
  });
};
